<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/taglibs.jsp" %>
<%@ taglib uri="/tag" prefix="tag"%>
<tag:customerLogonCheck/>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>增加收货地址</title>
<link href="${ctx }/style/common.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="../js/common.js"></script>

<script type="text/javascript">

function addNewAddress(){

		var consignee = $("#consignee").val();
		if( consignee == ""){
			 alert("请填写收货人姓名。");
			 return false;
		}
	    
		var province = $("#provinceInfoSelect").val();
		if( province == ""){
			 alert("请选择所在省。");
			 return false;
		}

		var city = $("#cityInfoSelect").val();
		if( city == ""){
			 alert("请选择所在市县。");
			 return false;
		}
		
		var address = $.trim($("#address").val());
		if( address  ==  ""){
			$("#address").focus();
			 alert("请填写街道地址。");
			 return false;
		}

	    var mobile = $("#mobile").val();
		if(!checkMobilePhone(mobile)){
			$("#mobile").focus();
			alert("请正确收货人手机号码。");
			return false;
		}

		var zipCode = $.trim($("#zipCode").val());
		var zipCodeReg = /^[1-9][0-9]{5}$/;
		if( zipCode != "" && !zipCodeReg.test(zipCode) ){
			$("#zipCode").focus();
			 alert("邮政编码填写不正确。");
			 return false;
		}

		if(window.confirm("确认提交？")){
			 $("#addressForm").submit();
		}else{
			return false;
		}
}

function return_to_list(){
	location.href = "${ctx}/customer/customerAction!listAddress.do";	
}

$(function(){

	var errorMessage = '${requestScope.errormessge}';
	if(errorMessage != ''){
		alert(errorMessage);
	}
	
	var city_id = '${addressInfo.cityInfo.id}';
	checkCity(city_id);
});
</script>

<style type="text/css">
#content{border: 0px solid #ccc;font-size: 14px;width: 960px;}
.style15 {color: #FF6600}
.input_table{padding: 3px 0px 5px 10px;}
.input{border: 1px solid #cccccc;-moz-border-radius: 3px;-webkit-border-radius: 3px;height: 18px;line-height: 17px;padding: 8px 5px 7px;width: 200px;font-size: 14px;}
</style>

</head>

<body>

	<%@include file="/commons/head.jsp"%>

	<%@include file="/user/customer_menu.jsp"%>
	
	<div id="modify_address_div" style="background: #ffffff;padding-bottom: 20px;border: 1px solid #ccc;width: 960px;margin: 0 auto;margin-top: 5px;">
		<div style="font-size: 26px;color: #FF6600;margin:20px 0px 0px 100px;">新增收货信息</div>
		<div id="content">
			<form action="${ctx }/customer/customerAction!saveAddressInfo.do" method="post" id="addressForm" name="addressForm">
				<table width="100%" border="0" cellpadding="0" cellspacing="10">
					<tr>
						<td align="right"><span class="style15">*</span>收货人</td>
						<td class="input_table">
							<input name="addressInfo.consignee" id="consignee" maxlength="50" size="30" value="${addressInfo.consignee }" class="input"/>
						</td>
					</tr>
					<tr>
						<td align="right"><span class="style15">*</span>收货地址</td>
						<td class="input_table">
							<div style="border: 1px solid #ccc;float: left;padding: 7px;">
								<select name="addressInfo.provinceInfo.id" id="provinceInfoSelect" onchange="changeProvince()">
			                        <option value="">选择省份</option>
			                        <c:forEach items="${requestScope.provinceInfoList}" var="provinceInfo" varStatus="status">
							            <option value="${ provinceInfo.id}" <c:if test="${addressInfo.provinceInfo.id == provinceInfo.id }">selected="selected"</c:if>> ${ provinceInfo.name}</option>
							        </c:forEach>
			                    </select>
		                    </div>
		                    <div style="border: 1px solid #ccc;float: left;margin-left: 5px;padding: 7px;">
			                    <select name="addressInfo.cityInfo.id" id="cityInfoSelect">
			                        <option>选择县市</option>
			                    </select>
		                    </div>
		                     &nbsp;<input name="addressInfo.address" id="address" value="${addressInfo.address }" maxlength="100" size="60" class="input" style="width: 400px;"/>
		                     <span style="font-size: 12px;">(请正确填写区域及街道地址)</span>
						</td>
					</tr>
					<tr>
						<td align="right"><span class="style15">*</span>收货人手机：</td>
						<td class="input_table">
							<input class="input" name="addressInfo.mobile" id="mobile" maxlength="20" size="30" value="${addressInfo.mobile }"/>
						</td>
					</tr>
					<tr>
						<td align="right">固定电话</td>
						<td class="input_table">
							<input class="input" name="addressInfo.telphone" id="telphone" maxlength="20" size="30" value="${addressInfo.mobile }"/>
						</td>
					</tr>
					<tr>
						<td align="right">邮政编码</td>
						<td class="input_table"><input class="input" name="addressInfo.zipCode" value="${addressInfo.zipCode }" id="zipCode" maxlength="20" size="30"/></td>
					</tr>
					<tr>
						<td width="130">
							<input name="addressInfo.id" id="addressInfo_id" maxlength="20" size="30" value="${addressInfo.id }" type="hidden"/>
						</td>
						<td class="input_table">
							<span><input type="button" onclick="addNewAddress()" style="cursor: pointer;padding: 5px 10px;" value="保存"/></span>
							<span style="padding-left: 50px;"><input type="button" onclick="return_to_list()" style="cursor: pointer;padding: 5px 10px;" value="返回收货地址列表"/></span>
						</td>
					</tr>
				</table>
			</form>
		</div>
	</div>

<%@ include file="/commons/foot.jsp" %>

</body>
</html>